x = [-0.3, -0.1, 0, 0.1, 0.3, 0.3, -0.3];
y = [1, 1, 0.2, 1, 1, -1, -1];

vert = [x', y'];
edge = zeros(7, 2);
edge(:, 1) = [1:7]';
edge(:, 2) = mod(edge(:, 1), 7) + 1; 

param = createParam(0.00001, 0.03, 0.0025, 0.1);

domain2D = createDomain(vert, edge, param);

% dim = size(domain2D.vx, 1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for frame = 1 : 200
    
    frame
    
    b = assemblyBoundaryVector(domain2D, frame);
    
    [A, Z] = assemblyMatrix(domain2D);

    theta = A \ b;

    u = evaluateInteriorPoint([domain2D.vx],[domain2D.vy], domain2D, theta);
    
    plotContour(domain2D, u(:,1), u(:,2), frame);

    F = evaluateInteriorDeformationGradient([domain2D.vx],[domain2D.vy], domain2D, theta);

    [S, C, R] = evaluateInteriorStress(F);

    [ pdir, pev ] = evaluatePrincipalInfo( S, domain2D );

    domain2D = updateTopology(pdir, pev);
    
end


